package com.atguigu.edusta.controller;


import com.atguigu.commonutils.R;
import com.atguigu.edusta.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2023-05-01
 */
@CrossOrigin
@RestController
@RequestMapping("/edusta/sta")
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService dailyService;

    /**
     * 获取每天的注册人数
     * 保存到另一张表中
     *
     * @return
     */
    @GetMapping("/registerCount/{day}")
    public R registerCount(@PathVariable String day) {
        dailyService.registerCount(day);
        return R.ok();
    }

    //图表显示，返回两部分数据，日期json数组，数量json数组
    @GetMapping("showData/{type}/{begin}/{end}")
    public R showData(@PathVariable String type, @PathVariable String begin,
                      @PathVariable String end) {
        Map<String, Object> map = dailyService.getShowData(type, begin, end);
        return R.ok().data(map);
    }
}

